\(\int \frac {(e+f x) \csc ^2(c+d x)}{a+a \sin (c+d x)} \, dx\) [205]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [B] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [F(-2)]
   Giac [F]
   Mupad [F(-1)]

Optimal result

Integrand size = 26, antiderivative size = 169 \[ \int \frac {(e+f x) \csc ^2(c+d x)}{a+a \sin (c+d x)} \, dx=\frac {2 (e+f x) \text {arctanh}\left (e^{i (c+d x)}\right )}{a d}-\frac {(e+f x) \cot \left (\frac {c}{2}+\frac {\pi }{4}+\frac {d x}{2}\right )}{a d}-\frac {(e+f x) \cot (c+d x)}{a d}+\frac {2 f \log \left (\sin \left (\frac {c}{2}+\frac {\pi }{4}+\frac {d x}{2}\right )\right )}{a d^2}+\frac {f \log (\sin (c+d x))}{a d^2}-\frac {i f \operatorname {PolyLog}\left (2,-e^{i (c+d x)}\right )}{a d^2}+\frac {i f \operatorname {PolyLog}\left (2,e^{i (c+d x)}\right )}{a d^2} \]

[Out]

2*(f*x+e)*arctanh(exp(I*(d*x+c)))/a/d-(f*x+e)*cot(1/2*c+1/4*Pi+1/2*d*x)/a/d-(f*x+e)*cot(d*x+c)/a/d+2*f*ln(sin(
1/2*c+1/4*Pi+1/2*d*x))/a/d^2+f*ln(sin(d*x+c))/a/d^2-I*f*polylog(2,-exp(I*(d*x+c)))/a/d^2+I*f*polylog(2,exp(I*(
d*x+c)))/a/d^2

Rubi [A] (verified)

Time = 0.15 (sec) , antiderivative size = 169, normalized size of antiderivative = 1.00, number of steps used = 12, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.269, Rules used = {4631, 4269, 3556, 4268, 2317, 2438, 3399} \[ \int \frac {(e+f x) \csc ^2(c+d x)}{a+a \sin (c+d x)} \, dx=\frac {2 (e+f x) \text {arctanh}\left (e^{i (c+d x)}\right )}{a d}-\frac {i f \operatorname {PolyLog}\left (2,-e^{i (c+d x)}\right )}{a d^2}+\frac {i f \operatorname {PolyLog}\left (2,e^{i (c+d x)}\right )}{a d^2}+\frac {2 f \log \left (\sin \left (\frac {c}{2}+\frac {d x}{2}+\frac {\pi }{4}\right )\right )}{a d^2}+\frac {f \log (\sin (c+d x))}{a d^2}-\frac {(e+f x) \cot \left (\frac {c}{2}+\frac {d x}{2}+\frac {\pi }{4}\right )}{a d}-\frac {(e+f x) \cot (c+d x)}{a d} \]

[In]

Int[((e + f*x)*Csc[c + d*x]^2)/(a + a*Sin[c + d*x]),x]

[Out]

(2*(e + f*x)*ArcTanh[E^(I*(c + d*x))])/(a*d) - ((e + f*x)*Cot[c/2 + Pi/4 + (d*x)/2])/(a*d) - ((e + f*x)*Cot[c
+ d*x])/(a*d) + (2*f*Log[Sin[c/2 + Pi/4 + (d*x)/2]])/(a*d^2) + (f*Log[Sin[c + d*x]])/(a*d^2) - (I*f*PolyLog[2,
 -E^(I*(c + d*x))])/(a*d^2) + (I*f*PolyLog[2, E^(I*(c + d*x))])/(a*d^2)

Rule 2317

Int[Log[(a_) + (b_.)*((F_)^((e_.)*((c_.) + (d_.)*(x_))))^(n_.)], x_Symbol] :> Dist[1/(d*e*n*Log[F]), Subst[Int
[Log[a + b*x]/x, x], x, (F^(e*(c + d*x)))^n], x] /; FreeQ[{F, a, b, c, d, e, n}, x] && GtQ[a, 0]

Rule 2438

Int[Log[(c_.)*((d_) + (e_.)*(x_)^(n_.))]/(x_), x_Symbol] :> Simp[-PolyLog[2, (-c)*e*x^n]/n, x] /; FreeQ[{c, d,
 e, n}, x] && EqQ[c*d, 1]

Rule 3399

Int[((c_.) + (d_.)*(x_))^(m_.)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[(2*a)^n, Int[(c
 + d*x)^m*Sin[(1/2)*(e + Pi*(a/(2*b))) + f*(x/2)]^(2*n), x], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && EqQ[a^2
- b^2, 0] && IntegerQ[n] && (GtQ[n, 0] || IGtQ[m, 0])

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 4268

Int[csc[(e_.) + (f_.)*(x_)]*((c_.) + (d_.)*(x_))^(m_.), x_Symbol] :> Simp[-2*(c + d*x)^m*(ArcTanh[E^(I*(e + f*
x))]/f), x] + (-Dist[d*(m/f), Int[(c + d*x)^(m - 1)*Log[1 - E^(I*(e + f*x))], x], x] + Dist[d*(m/f), Int[(c +
d*x)^(m - 1)*Log[1 + E^(I*(e + f*x))], x], x]) /; FreeQ[{c, d, e, f}, x] && IGtQ[m, 0]

Rule 4269

Int[csc[(e_.) + (f_.)*(x_)]^2*((c_.) + (d_.)*(x_))^(m_.), x_Symbol] :> Simp[(-(c + d*x)^m)*(Cot[e + f*x]/f), x
] + Dist[d*(m/f), Int[(c + d*x)^(m - 1)*Cot[e + f*x], x], x] /; FreeQ[{c, d, e, f}, x] && GtQ[m, 0]

Rule 4631

Int[(Csc[(c_.) + (d_.)*(x_)]^(n_.)*((e_.) + (f_.)*(x_))^(m_.))/((a_) + (b_.)*Sin[(c_.) + (d_.)*(x_)]), x_Symbo
l] :> Dist[1/a, Int[(e + f*x)^m*Csc[c + d*x]^n, x], x] - Dist[b/a, Int[(e + f*x)^m*(Csc[c + d*x]^(n - 1)/(a +
b*Sin[c + d*x])), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && IGtQ[m, 0] && IGtQ[n, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {\int (e+f x) \csc ^2(c+d x) \, dx}{a}-\int \frac {(e+f x) \csc (c+d x)}{a+a \sin (c+d x)} \, dx \\ & = -\frac {(e+f x) \cot (c+d x)}{a d}-\frac {\int (e+f x) \csc (c+d x) \, dx}{a}+\frac {f \int \cot (c+d x) \, dx}{a d}+\int \frac {e+f x}{a+a \sin (c+d x)} \, dx \\ & = \frac {2 (e+f x) \text {arctanh}\left (e^{i (c+d x)}\right )}{a d}-\frac {(e+f x) \cot (c+d x)}{a d}+\frac {f \log (\sin (c+d x))}{a d^2}+\frac {\int (e+f x) \csc ^2\left (\frac {1}{2} \left (c+\frac {\pi }{2}\right )+\frac {d x}{2}\right ) \, dx}{2 a}+\frac {f \int \log \left (1-e^{i (c+d x)}\right ) \, dx}{a d}-\frac {f \int \log \left (1+e^{i (c+d x)}\right ) \, dx}{a d} \\ & = \frac {2 (e+f x) \text {arctanh}\left (e^{i (c+d x)}\right )}{a d}-\frac {(e+f x) \cot \left (\frac {c}{2}+\frac {\pi }{4}+\frac {d x}{2}\right )}{a d}-\frac {(e+f x) \cot (c+d x)}{a d}+\frac {f \log (\sin (c+d x))}{a d^2}-\frac {(i f) \text {Subst}\left (\int \frac {\log (1-x)}{x} \, dx,x,e^{i (c+d x)}\right )}{a d^2}+\frac {(i f) \text {Subst}\left (\int \frac {\log (1+x)}{x} \, dx,x,e^{i (c+d x)}\right )}{a d^2}+\frac {f \int \cot \left (\frac {c}{2}+\frac {\pi }{4}+\frac {d x}{2}\right ) \, dx}{a d} \\ & = \frac {2 (e+f x) \text {arctanh}\left (e^{i (c+d x)}\right )}{a d}-\frac {(e+f x) \cot \left (\frac {c}{2}+\frac {\pi }{4}+\frac {d x}{2}\right )}{a d}-\frac {(e+f x) \cot (c+d x)}{a d}+\frac {2 f \log \left (\sin \left (\frac {c}{2}+\frac {\pi }{4}+\frac {d x}{2}\right )\right )}{a d^2}+\frac {f \log (\sin (c+d x))}{a d^2}-\frac {i f \operatorname {PolyLog}\left (2,-e^{i (c+d x)}\right )}{a d^2}+\frac {i f \operatorname {PolyLog}\left (2,e^{i (c+d x)}\right )}{a d^2} \\ \end{align*}

Mathematica [B] (verified)

Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(404\) vs. \(2(169)=338\).

Time = 6.96 (sec) , antiderivative size = 404, normalized size of antiderivative = 2.39 \[ \int \frac {(e+f x) \csc ^2(c+d x)}{a+a \sin (c+d x)} \, dx=\frac {\left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right ) \left (-d (e+f x) \cos \left (\frac {1}{2} (c+d x)\right ) \left (1+\cot \left (\frac {1}{2} (c+d x)\right )\right )+4 d (e+f x) \sin \left (\frac {1}{2} (c+d x)\right )-2 f (c+d x) \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+4 f \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right ) \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )-2 d e \log \left (\tan \left (\frac {1}{2} (c+d x)\right )\right ) \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+2 c f \log \left (\tan \left (\frac {1}{2} (c+d x)\right )\right ) \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+2 f (\log (\cos (c+d x))+\log (\tan (c+d x))) \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )-2 f \left ((c+d x) \left (\log \left (1-e^{i (c+d x)}\right )-\log \left (1+e^{i (c+d x)}\right )\right )+i \left (\operatorname {PolyLog}\left (2,-e^{i (c+d x)}\right )-\operatorname {PolyLog}\left (2,e^{i (c+d x)}\right )\right )\right ) \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+d (e+f x) \sin \left (\frac {1}{2} (c+d x)\right ) \left (1+\tan \left (\frac {1}{2} (c+d x)\right )\right )\right )}{2 a d^2 (1+\sin (c+d x))} \]

[In]

Integrate[((e + f*x)*Csc[c + d*x]^2)/(a + a*Sin[c + d*x]),x]

[Out]

((Cos[(c + d*x)/2] + Sin[(c + d*x)/2])*(-(d*(e + f*x)*Cos[(c + d*x)/2]*(1 + Cot[(c + d*x)/2])) + 4*d*(e + f*x)
*Sin[(c + d*x)/2] - 2*f*(c + d*x)*(Cos[(c + d*x)/2] + Sin[(c + d*x)/2]) + 4*f*Log[Cos[(c + d*x)/2] + Sin[(c +
d*x)/2]]*(Cos[(c + d*x)/2] + Sin[(c + d*x)/2]) - 2*d*e*Log[Tan[(c + d*x)/2]]*(Cos[(c + d*x)/2] + Sin[(c + d*x)
/2]) + 2*c*f*Log[Tan[(c + d*x)/2]]*(Cos[(c + d*x)/2] + Sin[(c + d*x)/2]) + 2*f*(Log[Cos[c + d*x]] + Log[Tan[c
+ d*x]])*(Cos[(c + d*x)/2] + Sin[(c + d*x)/2]) - 2*f*((c + d*x)*(Log[1 - E^(I*(c + d*x))] - Log[1 + E^(I*(c +
d*x))]) + I*(PolyLog[2, -E^(I*(c + d*x))] - PolyLog[2, E^(I*(c + d*x))]))*(Cos[(c + d*x)/2] + Sin[(c + d*x)/2]
) + d*(e + f*x)*Sin[(c + d*x)/2]*(1 + Tan[(c + d*x)/2])))/(2*a*d^2*(1 + Sin[c + d*x]))

Maple [B] (verified)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 368 vs. \(2 (149 ) = 298\).

Time = 0.43 (sec) , antiderivative size = 369, normalized size of antiderivative = 2.18

method result size
risch \(-\frac {2 \left (-2 f x +i {\mathrm e}^{i \left (d x +c \right )} f x -2 e +i {\mathrm e}^{i \left (d x +c \right )} e +f x \,{\mathrm e}^{2 i \left (d x +c \right )}+e \,{\mathrm e}^{2 i \left (d x +c \right )}\right )}{\left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) d a}+\frac {f \ln \left ({\mathrm e}^{i \left (d x +c \right )}+1\right ) x}{d a}-\frac {f \ln \left (1-{\mathrm e}^{i \left (d x +c \right )}\right ) x}{d a}+\frac {f \ln \left ({\mathrm e}^{i \left (d x +c \right )}-1\right )}{a \,d^{2}}+\frac {f \ln \left (1+{\mathrm e}^{2 i \left (d x +c \right )}\right )}{a \,d^{2}}+\frac {f \ln \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )}{a \,d^{2}}-\frac {2 i f \arctan \left ({\mathrm e}^{i \left (d x +c \right )}\right )}{a \,d^{2}}-\frac {e \ln \left ({\mathrm e}^{i \left (d x +c \right )}-1\right )}{d a}+\frac {e \ln \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )}{d a}+\frac {c f \ln \left ({\mathrm e}^{i \left (d x +c \right )}-1\right )}{d^{2} a}-\frac {f \ln \left (1-{\mathrm e}^{i \left (d x +c \right )}\right ) c}{d^{2} a}+\frac {i f \,\operatorname {Li}_{2}\left ({\mathrm e}^{i \left (d x +c \right )}\right )}{a \,d^{2}}-\frac {i f \,\operatorname {Li}_{2}\left (-{\mathrm e}^{i \left (d x +c \right )}\right )}{a \,d^{2}}-\frac {4 f \ln \left ({\mathrm e}^{i \left (d x +c \right )}\right )}{d^{2} a}\) \(369\)

[In]

int((f*x+e)*csc(d*x+c)^2/(a+a*sin(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

-2*(-2*f*x+I*exp(I*(d*x+c))*f*x-2*e+I*exp(I*(d*x+c))*e+f*x*exp(2*I*(d*x+c))+e*exp(2*I*(d*x+c)))/(exp(2*I*(d*x+
c))-1)/(exp(I*(d*x+c))+I)/d/a+1/d/a*f*ln(exp(I*(d*x+c))+1)*x-1/d/a*f*ln(1-exp(I*(d*x+c)))*x+1/a/d^2*f*ln(exp(I
*(d*x+c))-1)+1/a/d^2*f*ln(1+exp(2*I*(d*x+c)))+1/a/d^2*f*ln(exp(I*(d*x+c))+1)-2*I/a/d^2*f*arctan(exp(I*(d*x+c))
)-1/d/a*e*ln(exp(I*(d*x+c))-1)+1/d/a*e*ln(exp(I*(d*x+c))+1)+1/d^2/a*c*f*ln(exp(I*(d*x+c))-1)-1/d^2/a*f*ln(1-ex
p(I*(d*x+c)))*c+I*f*polylog(2,exp(I*(d*x+c)))/a/d^2-I*f*polylog(2,-exp(I*(d*x+c)))/a/d^2-4/d^2/a*f*ln(exp(I*(d
*x+c)))

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 858 vs. \(2 (145) = 290\).

Time = 0.32 (sec) , antiderivative size = 858, normalized size of antiderivative = 5.08 \[ \int \frac {(e+f x) \csc ^2(c+d x)}{a+a \sin (c+d x)} \, dx=\text {Too large to display} \]

[In]

integrate((f*x+e)*csc(d*x+c)^2/(a+a*sin(d*x+c)),x, algorithm="fricas")

[Out]

-1/2*(2*d*f*x - 4*(d*f*x + d*e)*cos(d*x + c)^2 + 2*d*e - 2*(d*f*x + d*e)*cos(d*x + c) + (-I*f*cos(d*x + c)^2 +
 (I*f*cos(d*x + c) + I*f)*sin(d*x + c) + I*f)*dilog(cos(d*x + c) + I*sin(d*x + c)) + (I*f*cos(d*x + c)^2 + (-I
*f*cos(d*x + c) - I*f)*sin(d*x + c) - I*f)*dilog(cos(d*x + c) - I*sin(d*x + c)) + (-I*f*cos(d*x + c)^2 + (I*f*
cos(d*x + c) + I*f)*sin(d*x + c) + I*f)*dilog(-cos(d*x + c) + I*sin(d*x + c)) + (I*f*cos(d*x + c)^2 + (-I*f*co
s(d*x + c) - I*f)*sin(d*x + c) - I*f)*dilog(-cos(d*x + c) - I*sin(d*x + c)) + (d*f*x - (d*f*x + d*e + f)*cos(d
*x + c)^2 + d*e + (d*f*x + d*e + (d*f*x + d*e + f)*cos(d*x + c) + f)*sin(d*x + c) + f)*log(cos(d*x + c) + I*si
n(d*x + c) + 1) + (d*f*x - (d*f*x + d*e + f)*cos(d*x + c)^2 + d*e + (d*f*x + d*e + (d*f*x + d*e + f)*cos(d*x +
 c) + f)*sin(d*x + c) + f)*log(cos(d*x + c) - I*sin(d*x + c) + 1) + ((d*e - (c + 1)*f)*cos(d*x + c)^2 - d*e +
(c + 1)*f - (d*e - (c + 1)*f + (d*e - (c + 1)*f)*cos(d*x + c))*sin(d*x + c))*log(-1/2*cos(d*x + c) + 1/2*I*sin
(d*x + c) + 1/2) + ((d*e - (c + 1)*f)*cos(d*x + c)^2 - d*e + (c + 1)*f - (d*e - (c + 1)*f + (d*e - (c + 1)*f)*
cos(d*x + c))*sin(d*x + c))*log(-1/2*cos(d*x + c) - 1/2*I*sin(d*x + c) + 1/2) - (d*f*x - (d*f*x + c*f)*cos(d*x
 + c)^2 + c*f + (d*f*x + c*f + (d*f*x + c*f)*cos(d*x + c))*sin(d*x + c))*log(-cos(d*x + c) + I*sin(d*x + c) +
1) - (d*f*x - (d*f*x + c*f)*cos(d*x + c)^2 + c*f + (d*f*x + c*f + (d*f*x + c*f)*cos(d*x + c))*sin(d*x + c))*lo
g(-cos(d*x + c) - I*sin(d*x + c) + 1) - 2*(f*cos(d*x + c)^2 - (f*cos(d*x + c) + f)*sin(d*x + c) - f)*log(sin(d
*x + c) + 1) - 2*(d*f*x + d*e + 2*(d*f*x + d*e)*cos(d*x + c))*sin(d*x + c))/(a*d^2*cos(d*x + c)^2 - a*d^2 - (a
*d^2*cos(d*x + c) + a*d^2)*sin(d*x + c))

Sympy [F]

\[ \int \frac {(e+f x) \csc ^2(c+d x)}{a+a \sin (c+d x)} \, dx=\frac {\int \frac {e \csc ^{2}{\left (c + d x \right )}}{\sin {\left (c + d x \right )} + 1}\, dx + \int \frac {f x \csc ^{2}{\left (c + d x \right )}}{\sin {\left (c + d x \right )} + 1}\, dx}{a} \]

[In]

integrate((f*x+e)*csc(d*x+c)**2/(a+a*sin(d*x+c)),x)

[Out]

(Integral(e*csc(c + d*x)**2/(sin(c + d*x) + 1), x) + Integral(f*x*csc(c + d*x)**2/(sin(c + d*x) + 1), x))/a

Maxima [F(-2)]

Exception generated. \[ \int \frac {(e+f x) \csc ^2(c+d x)}{a+a \sin (c+d x)} \, dx=\text {Exception raised: RuntimeError} \]

[In]

integrate((f*x+e)*csc(d*x+c)^2/(a+a*sin(d*x+c)),x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: THROW: The catch RAT-ERR is undefined.

Giac [F]

\[ \int \frac {(e+f x) \csc ^2(c+d x)}{a+a \sin (c+d x)} \, dx=\int { \frac {{\left (f x + e\right )} \csc \left (d x + c\right )^{2}}{a \sin \left (d x + c\right ) + a} \,d x } \]

[In]

integrate((f*x+e)*csc(d*x+c)^2/(a+a*sin(d*x+c)),x, algorithm="giac")

[Out]

integrate((f*x + e)*csc(d*x + c)^2/(a*sin(d*x + c) + a), x)

Mupad [F(-1)]

Timed out. \[ \int \frac {(e+f x) \csc ^2(c+d x)}{a+a \sin (c+d x)} \, dx=\text {Hanged} \]

[In]

int((e + f*x)/(sin(c + d*x)^2*(a + a*sin(c + d*x))),x)

[Out]

\text{Hanged}